from django.db import models

# Create your models here.
from django.contrib.auth.models import AbstractUser


# 用户表
class User(AbstractUser):
    # 继承原来的auth表，拓展字段，不要与原来有的字段名重复
    email = models.EmailField(verbose_name='邮箱', default='2414155342@qq.com')
    telephone = models.CharField(max_length=11, verbose_name='手机号码', null=True)
    icon = models.FileField(upload_to='icon', default='/icon/default.jpg/', verbose_name='用户头像')
    name = models.CharField(max_length=12, verbose_name='用户姓名', null=True)
    sid = models.CharField(max_length=24, verbose_name='身份证', null=True)
    sex = models.IntegerField(choices=((1, '男'), (0, '女')), default=1, verbose_name='性别')
    role = models.IntegerField(choices=((1, '超级管理员'), (2, '管理员'), (3, '经理'), (4, '普通员工')), default=4,verbose_name='用户角色')
    position = models.ForeignKey(to='Position', on_delete=models.CASCADE, null=True, verbose_name='职位')
    parts = models.IntegerField(choices=((1, '行政部'), (2, '人事部'), (3, '开发部'), (4, '财务部'), (5, '老板部')),
                                verbose_name='所在部门', null=True)
    desc = models.CharField(max_length=40, verbose_name='职位描述', default='员工')
    barthday = models.DateTimeField(verbose_name='出生日期', null=True)
    intime = models.DateField(verbose_name='入职时间', auto_now=True)
    outtime = models.DateField(verbose_name='辞职时间', null=True)
    is_active = models.BooleanField(default=True, verbose_name='是否在职')
    wetchat = models.CharField(max_length=30, verbose_name='微信号', null=True)
    salarys = models.ForeignKey(to='Salary', on_delete=models.CASCADE, verbose_name='工资', null=True)
    is_show = models.BooleanField(default=True, verbose_name='是否展示给前端')
    part_f = models.ForeignKey(to='Part', on_delete=models.CASCADE, default=1)
    change = models.DateTimeField(auto_now=True,verbose_name='更新用户信息后，最新显示出来')

    def __str__(self):
        return self.username

    # 返回部门名字
    @property
    def part_name(self):
        return self.get_parts_display()

    # 返回性别的中文
    @property
    def sex_name(self):
        return self.get_sex_display()

    # 返回员工角色
    @property
    def role_name(self):
        return self.get_role_display()

    # 返回员工的职位
    @property
    def get_position(self):
        return self.position.name

    @property  # 拿到部门名字
    def get_part_f(self):
        return self.part_f.name


# 工资表
class Salary(models.Model):
    create_time = models.DateTimeField(verbose_name='发的是哪个月的工资',null=True,auto_now_add=True)
    salary = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='基本工资')
    users = models.ForeignKey(to='User', on_delete=models.CASCADE, verbose_name='职员')
    overwork = models.FloatField(verbose_name='加班工资',null=True)
    leave = models.FloatField(verbose_name='请假扣的钱',null=True)
    absent = models.FloatField(verbose_name='旷工花的钱',null=True)
    m_time = models.DateField(verbose_name='发工资时间')
    is_send = models.BooleanField(default=False, verbose_name='工资是否发放')
    last_salary = models.FloatField(verbose_name='最后工资',null=True)
    def __str__(self):
        return self.users.username + ":" + str(self.salary)
    # 返回职员名字
    @property
    def username(self):
        return self.users.name

    class Meta:
        verbose_name_plural = '工资表'


# 职位表
class Position(models.Model):
    name = models.CharField(max_length=30, verbose_name='职位名')
    pnumber = models.CharField(max_length=10, verbose_name='职位编号',null=True)
    part = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='所属部门')
    create_time= models.DateTimeField(auto_now_add=True,null=True)
    desc = models.CharField(max_length=100,verbose_name='职位描述',null=True)

    class Meta:
        verbose_name = '职位表'
        verbose_name_plural = '职位表'

    def __str__(self):
        return self.name
    @property
    def part_name(self):
        return self.part.name


# 部门表
class Part(models.Model):
    '''
    number就是每个部门的用户名的开头，
    每个部门经理使用的账户，只有这个账户才能操作部门经理界面
    先创建部门，在创建用户的时候，给部门绑定上部门经理
    '''
    number = models.CharField(max_length=10, verbose_name='部门编号', unique=True)
    name = models.CharField(max_length=20, verbose_name='部门名称', unique=True)
    desc = models.CharField(max_length=100, verbose_name='部门信息')
    manager = models.ForeignKey(to='User', on_delete=models.CASCADE, verbose_name='部门的经理id', null=True)
    is_delete = models.BooleanField(default=False)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = '部门表'
        verbose_name_plural = '部门表'

    # 返回的是管理员的名字，序列化使用的
    @property
    def managername(self):
        return self.manager.name

    @property
    def partname(self):
        return self.name+self.number[0:3]


# 出勤表
class Attendance(models.Model):
    user = models.ForeignKey(to='User', on_delete=models.CASCADE, null=True, verbose_name='职员')
    startime = models.DateTimeField(verbose_name='上班打卡时间',null=True)
    endtime = models.DateTimeField(verbose_name='下班打卡时间',null=True)
    is_leave = models.BooleanField(default=False, verbose_name='是否请假')
    is_evection = models.BooleanField(default=False, verbose_name='是否出差')
    is_delay = models.BooleanField(default=False, verbose_name='是否迟到')
    is_before = models.BooleanField(default=False, verbose_name='是否早退')
    create = models.DateTimeField(auto_now_add=True,verbose_name='创建时间',null=True)
    long_time = models.SmallIntegerField(default=0,verbose_name='工作时长')
    class Meta:
        verbose_name = '出勤表'
        verbose_name_plural = '出勤表'
    def __str__(self):
        return self.user.username + '出勤情况'
    def _is_delay(self):
        if self.is_delay:
            return '是'
        else:
            return '否'
    def _is_before(self):
        if self.is_before:
            return '是'
        else:
            return '否'
    def _is_leave(self):
        if self.is_leave:
            return '是'
        else:
            return '否'
    def _is_evection(self):
        if self.is_evection:
            return '是'
        else:
            return '否'

#公司签到时间
class SignTime(models.Model):
    hour = models.SmallIntegerField(verbose_name='小时')
    min = models.SmallIntegerField(verbose_name='分钟')
    the_type = models.BooleanField(default=False,verbose_name='true 是签到时间，false是签退时间')
#每月应该签到天数
class MonthSignCount(models.Model):
    year_month = models.DateField(verbose_name='年月')
    sign_days = models.SmallIntegerField(verbose_name='签到次数')
    create = models.DateTimeField(auto_now_add=True)


# 任务表
class Mission(models.Model):
    leader = models.ForeignKey(to='User', on_delete=models.CASCADE, verbose_name='任务发起者')
    desc = models.CharField(max_length=200, verbose_name='任务描述')
    part = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='部门')
    recver = models.CharField(max_length=100, verbose_name='指定操作人员', null=True)
    starttime = models.DateTimeField(verbose_name='任务开始时间')
    endtime = models.DateTimeField(verbose_name='任务结束时间')
    file = models.FileField(upload_to='mission', verbose_name='任务说明文件')
    is_end = models.BooleanField(default=False, verbose_name='任务是否结束')

    def __str__(self):
        return self.leader.username + ':' + '发起的任务'

    class Meta:
        verbose_name = '任务表'
        verbose_name_plural = '任务表'


# 报销表被弃用了。
class Reimbursement(models.Model):
    reuser = models.ForeignKey(to='User', on_delete=models.CASCADE, verbose_name='报销人')
    money = models.DecimalField(max_digits=7, decimal_places=2, verbose_name='报销金额')
    times = models.DateTimeField(verbose_name='报销时间')
    desc = models.CharField(max_length=100, verbose_name='报销备注')
    image = models.ImageField(upload_to='reimbur', verbose_name='报销照片文件夹')
    part = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='所在部门')
    one_result = models.BooleanField(default=False, verbose_name='一级审核结果')
    two_result = models.BooleanField(default=False, verbose_name='二级审核结果')
    one_opetion = models.IntegerField(choices=((1, '未审核'), (2, '审核未通过'), (3, '审核通过')), default=1)
    two_opetion = models.IntegerField(choices=((1, '未审核'), (2, '审核未通过'), (3, '审核通过')), default=1)
    one_result_default = models.CharField(max_length=100, verbose_name='一级不通过原因')
    tow_result_default = models.CharField(max_length=100, verbose_name='一级不通过原因')
    finaly_result = models.BooleanField(default=False, verbose_name='最终的审核结果')

    class Meta:
        verbose_name = '报销表'
        verbose_name_plural = '报销表'

    # 返回审核情况：通过、未审核、审核失败
    @property
    def one_opetion_re(self):
        return self.get_one_opetion_display()

    @property
    def two_opetion_re(self):
        return self.get_two_opetion_display()


# 审核人的表
class Checker(models.Model):
    part = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='所在部门')
    partmanager = models.ForeignKey(to='User', on_delete=models.CASCADE, verbose_name='部门经理')
    boos = models.CharField(default='311000', max_length=10, verbose_name='老板')
    class Meta:
        verbose_name = '审核人表'
        verbose_name_plural = '审核人表'


# 公司公告
class CompanyMessage(models.Model):

    title = models.CharField(max_length=100, verbose_name='通知标题')
    desc = models.CharField(max_length=200, verbose_name='通知描述')
    content = models.TextField(verbose_name='通知内容')
    created = models.DateField(auto_now_add=True,verbose_name='创建时间',null=True)
    is_show = models.BooleanField(default=True,verbose_name='是否展示')

    class Meta:
        verbose_name = '公司公告表'
        verbose_name_plural = '公司公告表'


# 部门通知
class PartMessage(models.Model):
    title = models.CharField(max_length=100, verbose_name='通知标题')
    desc = models.CharField(max_length=200, verbose_name='通知描述')
    content = models.CharField(max_length=1000, verbose_name='通知内容')
    created = models.DateField(auto_now=True, verbose_name='创建时间', null=True)
    is_show = models.BooleanField(default=True, verbose_name='是否展示')
    part = models.ForeignKey(to='Part',on_delete=models.CASCADE,verbose_name='部门',null=True)
    class Meta:
        verbose_name = '部门通知表'
        verbose_name_plural = '部门通知表'


# 出差表
class Evection(models.Model):
    position = models.CharField(max_length=200, verbose_name='出差地点')
    start = models.DateField(verbose_name='出差开始时间')
    end = models.DateField(verbose_name='出差结束时间')
    checker = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='审核人',null=True)
    apllier = models.ForeignKey(to='User',on_delete=models.CASCADE,verbose_name='申请发起人',null=True)
    desc = models.CharField(max_length=300,verbose_name='出差描述',null=True)
    condition = models.IntegerField(choices=((1, '未审核'), (2, '审核通过'), (3, '审核不通过')), verbose_name='审核情况',default=1)
    result = models.CharField(max_length=200, verbose_name='审核结果', null=True)
    is_back = models.BooleanField(default=False, verbose_name='是否结束出差')
    days = models.SmallIntegerField(verbose_name='出差天数',null=True)
    is_delete = models.BooleanField(default=False,verbose_name='是否删除')
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='用来进行排序',null=True)
    class Meta:
        verbose_name = '出差表'
        verbose_name_plural = '出差表'
    # 审核情况
    @property
    def the_condicion(self):
        return self.get_condition_display()


# 加班表
class ExtraWork(models.Model):
    start = models.DateTimeField(verbose_name='加班开始时间')
    end = models.DateTimeField(verbose_name='加班结束时间')
    hours = models.SmallIntegerField(default=0,verbose_name='加班时长')
    desc = models.CharField(max_length=300, verbose_name='加班内容描述')
    image = models.ImageField(upload_to='extrawork', verbose_name='加班图片')
    checker = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='审核人',null=True)
    condition = models.IntegerField(choices=((1, '未审核'), (2, '审核通过'), (3, '审核不通过')), verbose_name='审核情况',default=1)
    result = models.CharField(max_length=200, verbose_name='审核结果', null=True)
    is_back = models.BooleanField(default=False, verbose_name='是否结束加班')
    applier = models.ForeignKey(to='User',on_delete=models.CASCADE,null=True)
    is_delete = models.BooleanField(default=False,verbose_name='是否删除')

    class Meta:
        verbose_name = '加班表'
        verbose_name_plural = '加班表'

    # 审核情况
    @property
    def the_condicion(self):
        return self.get_condition_display()


# 用车申请表
class UserCar(models.Model):
    licenseplate = models.CharField(max_length=200, verbose_name='车牌')
    start = models.DateTimeField(verbose_name="开始使用时间")
    end = models.DateTimeField(verbose_name='结束时间')
    position = models.CharField(max_length=200, verbose_name='终点')
    checker = models.ForeignKey(to='Checker', on_delete=models.CASCADE, verbose_name='审核人')
    condition = models.IntegerField(choices=((1, '未审核'), (2, '审核通过'), (3, '审核不通过')), verbose_name='审核情况')
    result = models.CharField(max_length=200, verbose_name='审核结果', null=True)
    is_back = models.BooleanField(default=True, verbose_name='是否结束出差')

    class Meta:
        verbose_name = '用车申请表'
        verbose_name_plural = '用车申请表'

    # 审核情况
    @property
    def the_condicion(self):
        return self.get_condition_display()


# 公司文件
class CompanyFile(models.Model):
    filename = models.FileField(upload_to='companyfile', verbose_name='公司文件')
    name = models.CharField(max_length=40,null=True)
    desc = models.CharField(max_length=200, verbose_name='文件描述')
    upload = models.ForeignKey(to='User', verbose_name='文件上传者', on_delete=models.CASCADE)
    created = models.DateField(auto_now=True, verbose_name='创建时间', null=True)
    is_show = models.IntegerField(default=True, verbose_name='是否展示')

    class Meta:
        verbose_name = '公司文件表'
        verbose_name_plural = '公司文件表'


# 员工档案文件
class Record(models.Model):
    staff = models.OneToOneField(to='User', on_delete=models.CASCADE, verbose_name='员工')#员工是唯一的，一个人只能有一个档案
    part = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='部门')
    file = models.FileField(upload_to='recordfile', verbose_name='档案文件')
    is_delete = models.BooleanField(default=False,verbose_name='是否删除')
    class Meta:
        verbose_name = '员工档案表'
        verbose_name_plural = '员工档案表'
    @property
    def name(self):
        return self.part.name+'_'+self.staff.name
class Conference(models.Model):
    position=models.CharField(max_length=30,verbose_name='会议室位置')
    room = models.CharField(max_length=20,verbose_name='会议室号',unique=True)
    lager = models.SmallIntegerField(verbose_name='最多可容纳多少员工')
    is_delete = models.BooleanField(default=False)
    @property
    def room_lager(self):
        return self.room+'室-'+str(self.lager)+'人'

class ApllyConference(models.Model):
    start = models.DateTimeField(verbose_name='开始时间')
    end = models.DateTimeField(verbose_name='结束时间')
    checker = models.ForeignKey(to='Part',on_delete=models.CASCADE,verbose_name='审核人')
    applier = models.ForeignKey(to='User',on_delete=models.CASCADE,verbose_name='申请人')
    number = models.SmallIntegerField(verbose_name='开会人数')
    position = models.IntegerField(choices=((1,'待审核'),(2,'审核通过'),(3,'审核不通过')),default=1)
    result = models.CharField(max_length=200,verbose_name='审核不通过的原因')
    is_delete = models.BooleanField(default=False)
    conference = models.ForeignKey(to='Conference',on_delete=models.CASCADE,null=True,verbose_name='会议室')




class  Contract(models.Model):
    staff = models.OneToOneField(to='User', on_delete=models.CASCADE, verbose_name='员工')  # 员工是唯一的，一个人只能有一个档案
    part = models.ForeignKey(to='Part', on_delete=models.CASCADE, verbose_name='部门')
    file = models.FileField(upload_to='contract', verbose_name='合同文件')
    is_delete = models.BooleanField(default=False, verbose_name='是否删除')

    class Meta:
        verbose_name = '员工合同表'
        verbose_name_plural = '员工合同表'

    @property
    def name(self):
        return self.part.name + '_' + self.staff.name
# 前端需要的用户权限数据表：
'''
{
	data:{id:500,rid:0,username:'admin',token:''},
	//rights是用户所具备的权限的数据
	rights:[
        {id:10,authName:'用户管理',icon:'icon-user',children:[
            { id:11,authName:'创建用户',path:'createuser',rights:['add']}
            {}
        ]
        },
        
        {}
	]
}
'''

#一级导航的表
class EmunFather(models.Model):
    authName = models.CharField(max_length=10, verbose_name='一级导航名字')
    icon = models.CharField(max_length=50,verbose_name='文本图标')
    role = models.IntegerField(choices=((1, '超级管理员'), (2, '管理员'), (3, '经理'), (4, '普通员工')), default=4,verbose_name='用户角色')
    desc= models.CharField(max_length=50,verbose_name='描述',null=True)
    admin = models.IntegerField(choices=((1, '超级管理员'), (2, '管理员'), (3, '经理'), (4, '普通员工')), default=4,verbose_name='给管理员的附加权限')
    manager=models.IntegerField(choices=((1, '超级管理员'), (2, '管理员'), (3, '经理'), (4, '普通员工')), default=4,verbose_name='给经理的附加权限')
    part=models.ForeignKey(to='Part',on_delete=models.CASCADE,null=True,verbose_name='某个部门经理独有的功能')
    boss = models.IntegerField(choices=((1, '超级管理员'), (2, '管理员'), (3, '经理'), (4, '普通员工')), default=4,verbose_name='给老板的界面')
    create = models.DateTimeField(auto_now_add=True,null=True)

#二级导航的表
class EmnuChildren(models.Model):
    authName = models.CharField(max_length=15,verbose_name='二级导航名字')
    path = models.CharField(max_length=50,verbose_name='前端路由')
    right = models.CharField(max_length=30,verbose_name='视图权限，增、删、改、查')
    father = models.ForeignKey(to='EmunFather',on_delete=models.CASCADE,verbose_name='属于的一级导航')
    component = models.CharField(max_length=30,verbose_name='组件名，小写',default='')
    desc= models.CharField(max_length=50,verbose_name='描述',null=True)
    # part = models.ForeignKey(to='User',on_delete=models.CASCADE,verbose_name='所属部门',null=)

#二级导航中按键权限的表
class EmnuChildrenRight(models.Model):
    name = models.CharField(max_length=20,verbose_name='路由名字')
    right = models.CharField(max_length=6,verbose_name='add,view,delete,edit')
    father = models.ForeignKey(to='EmnuChildren',on_delete=models.CASCADE,verbose_name='属于二级导航中的某个路由')

#年份：一年内的所有日志中的数量

class YearLogData(models.Model):
    year = models.CharField(max_length=4,verbose_name='年份')
    def __str__(self):
        return self.year
class DetalLogdata(models.Model):
    year = models.ForeignKey(to='YearLogData',on_delete=models.CASCADE)
    mount = models.CharField(max_length=3,verbose_name='月份')
    count = models.IntegerField(verbose_name='告警数量')
    type = models.CharField(max_length=10,verbose_name='告警类型')
    order = models.SmallIntegerField(verbose_name='用来进行排序的',default=1)
    @property
    def get_year(self):
        return self.year.year
#车辆表
class Car(models.Model):
    carnumber = models.CharField(max_length=40,verbose_name='车牌号',unique=True)
    cartype = models.CharField(max_length=40,verbose_name='车辆型号')
    carseat = models.CharField(verbose_name='几座',null=True,max_length=50)
    is_delete = models.BooleanField(default=False,verbose_name='是否删除')
    @property
    def value(self):
        return self.id
    @property
    def label(self):
        return self.cartype+':'+self.carseat
    @property
    def car(self):
        return self.carnumber+"-"+self.carseat
#申请用车表
class ApplyCar(models.Model):
    start = models.DateTimeField()
    end = models.DateTimeField()
    hours=models.SmallIntegerField(verbose_name='使用时长',null=True)
    position = models.CharField(max_length=200,verbose_name='前往地点')
    is_back = models.BooleanField(default=False,verbose_name='是否还回车辆')
    desc = models.CharField(max_length=200,verbose_name='车辆描述')
    checker = models.ForeignKey(to='Part',on_delete=models.CASCADE,default=2)
    #审核用车申请的是行政部
    condition = models.IntegerField(choices=((1,'未审核'),(2,'审核通过'),(3,'审核不通过')),default=1)
    applier=models.ForeignKey(to='User',on_delete=models.CASCADE)
    car = models.ForeignKey(to='Car',on_delete=models.CASCADE,null=True)
    is_delete = models.BooleanField(default=False)
    result = models.CharField(max_length=200,verbose_name='审核结果',null=True)

#员工报销表
class Reim(models.Model):
    create = models.DateTimeField(null=True,auto_now_add=True)
    part = models.ForeignKey(to='Part',on_delete=models.CASCADE,verbose_name='审核部门')
    desc = models.CharField(max_length=200,verbose_name='报销描述')
    cost = models.FloatField(verbose_name='金额超过500转给老板')
    image = models.ImageField(upload_to='rembur',verbose_name='发票图片',null=True)
    condition = models.IntegerField(choices=((1,'未审核'),(2,'审核通过'),(3,'审核不通过')),default=1)
    result = models.CharField(max_length=200,verbose_name='审核不通过原因',null=True)
    applier = models.ForeignKey(to='User',on_delete=models.CASCADE,verbose_name='申请人')
    is_delete = models.BooleanField(default=False,null=True)
#任务表
class Task(models.Model):
    name = models.CharField(max_length=100,verbose_name='任务名称',null=True,unique=True)
    manage = models.ForeignKey(to='Part',on_delete=models.CASCADE,verbose_name='项目发起人')
    desc = models.CharField(max_length=200,verbose_name='项目描述')
    file = models.FileField(upload_to='mission',null=True,verbose_name='项目文件')
    start = models.DateField(verbose_name='项目开始时间')
    end = models.DateField(verbose_name='项目结束时间')
    #第三张中的这个表的外键要在前面
    tasktostaff = models.ManyToManyField(to='TaskDetail',through='TaskToDetail',through_fields=('task',"staff"))
    is_delete = models.BooleanField(default=False)
    is_end = models.BooleanField(default=False)

class TaskDetail(models.Model):
    staff = models.ForeignKey(to='User',on_delete=models.CASCADE,verbose_name='任务书写者')
    content = models.CharField(max_length=200,verbose_name='完成的什么功能')
    create = models.DateTimeField(auto_now_add=True)

class TaskToDetail(models.Model):
    staff = models.ForeignKey(to='TaskDetail',on_delete=models.CASCADE,verbose_name='员工')
    task = models.ForeignKey(to='Task',on_delete=models.CASCADE,verbose_name='项目')

class Level(models.Model):
    number = models.SmallIntegerField(default=1)
    desc = models.CharField(max_length=20,verbose_name='等级描述')
    type = models.CharField(max_length=40,verbose_name='按钮颜色',null=True)
#员工个人任务大概
class StaffTask(models.Model):
    create = models.DateTimeField(auto_now_add=True,null=True)
    apllier = models.ForeignKey(to='Part',on_delete=models.CASCADE,verbose_name='任务发起人')
    recever = models.ForeignKey(to='User',on_delete=models.CASCADE,verbose_name='任务负责人')
    end = models.DateTimeField(verbose_name='任务最晚结束时间')
    level = models.ForeignKey(to='Level',on_delete=models.CASCADE,verbose_name='任务等级')
    name = models.CharField(max_length=100,verbose_name='任务名称',null=True)
    desc = models.CharField(max_length=200,verbose_name='任务描述')
    file = models.FileField(upload_to='stafftask',verbose_name='任务文件')
    is_end = models.BooleanField(default=False,verbose_name='任务是否完成')
    is_del = models.BooleanField(default=False,verbose_name='任务是否删除')
#对员工个人任务中，完成任务的过程。
class TaskStep(models.Model):
    create = models.DateTimeField(auto_now_add=True,verbose_name='任务填写时间')
    content = models.CharField(max_length=300,verbose_name='完成任务的哪个功能')
    stafftask = models.ForeignKey(to='StaffTask',on_delete=models.CASCADE,verbose_name='属于哪个任务')
class Reword(models.Model):
    part = models.ForeignKey(to='Part',on_delete=models.CASCADE)
    position = models.ForeignKey(to='Position',on_delete=models.CASCADE,verbose_name='职位')
    cash = models.IntegerField(default=200,verbose_name='奖励的金额')

class MonthOfStaffSign(models.Model):
    staff = models.ForeignKey(to='User',on_delete=models.CASCADE,verbose_name='员工')
    month = models.DateField(verbose_name='那个月份的情况')
    leave_days = models.SmallIntegerField(verbose_name='请假天数',default=0)
    delay_count = models.SmallIntegerField(verbose_name='迟到次数',default=0)
    before_count = models.SmallIntegerField(verbose_name='早退次数',default=0)
    extra_hour = models.IntegerField(verbose_name='加班时长',default=0)
    word_days = models.SmallIntegerField(verbose_name='这月上班天数',default=0)
    de_reword = models.IntegerField(default=200,verbose_name='每月项目奖励')
    reword = models.ForeignKey(to='Reword',on_delete=models.CASCADE,verbose_name='外键实现项目奖励',null=True)
    busi_trip = models.SmallIntegerField(verbose_name='出差天数',default=0)
    create_time = models.DateTimeField(auto_now_add=True)
    #每月就一条记录


